<?php
use \GatewayWorker\Lib\Gateway;


class cmd_voteclear extends cmdbase
{
	public function onCmd($msg){

		//存起来(跨服需要) 1
		$group_mgr = $GLOBALS['GroupMgr'];
		$member_infos = $group_mgr->getSplMemberInfos($this->getCurGroupId());
		foreach ($member_infos as $member_info) {
			//离线玩家重置
			$member_info->support_type = SupportType::Invalid;
		}
		
		//广播
		$uid_list = Gateway::getUidListByGroup($this->getCurGroupId());
		$notify_vote = new notify_voteclear();
		$notify_vote->uid = $this->getCurUid();
		$notify_vote->simplemember_infos = array();
		foreach ($uid_list as $uid) {
			$simplemember_info = new simplemember_info();
			$simplemember_info->uid = $uid;
			$simplemember_info->support_type = SupportType::Invalid;
			$notify_vote->simplemember_infos[] = $simplemember_info;
			
			//存起来(跨服需要) 2
			$splmember_info = new splmember_info();
			$splmember_info->uid = $uid;
			$splmember_info->support_type = SupportType::Invalid;
			$splmember_info->card_type = CardType::Invalid;
			$member_infos[$uid] = $splmember_info;
		}
		$this->sendToGroup(notify_voteclear::class, $notify_vote);

		//存起来(跨服需要) 3
		$group_mgr->setSplMemberInfos($this->getCurGroupId(), $member_infos);

		//测试代码
		//$test = $group_mgr->getSplMemberInfos($this->getCurGroupId());
		//var_dump($test);

		$msg_ret = new voteclear_rsp();
		$msg_ret->ret = NetErrorCode::None;
		return $msg_ret;
	}
}